﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace HWR_Ants.Classes.Obsolete
{
    [Obsolete]
    class PointWithDistances
    {
        string id;
        Point point;
        SortedList<string, Point> listOfEndPoints;
        SortedList<string, double> listOfDistances;

        public string Id
        {
            get { return id; }
            set { id = value; }
        }

        public Point Point
        {
            get { return point; }
            set { point = value; }
        }

        public SortedList<string, Point> ListOfEndPoints
        {
            get { return listOfEndPoints; }
            set { listOfEndPoints = value; }
        }

        public SortedList<string, double> ListOfDistances
        {
            get { return listOfDistances; }
            set { listOfDistances = value; }
        }

        public PointWithDistances(string Id, SortedList<string, Point> sortedListOfPoints)
        {
            id = Id;
            sortedListOfPoints.TryGetValue(Id, out point);
            listOfDistances = new SortedList<string, double>();
            listOfEndPoints = new SortedList<string, Point>();

            foreach (string element in sortedListOfPoints.Keys)
            {
                if (element != id)
                {
                    Point tempPoint;
                    sortedListOfPoints.TryGetValue(element, out tempPoint);
                    listOfEndPoints.Add(element, tempPoint);
                    listOfDistances.Add(element, pythagoras(point, tempPoint));
                }
            }
        }

        private double pythagoras(Point X, Point Y)
        {
            Point Z = new Point(Y.X, X.Y);
            int length_X_Z = Math.Abs(X.X - Z.X);
            int length_Y_Z = Math.Abs(Y.Y - Z.Y);
            double ret = Math.Sqrt(Math.Pow((double)length_X_Z, 2) + Math.Pow((double)length_Y_Z, 2));

            return ret;
        }

        public double getDistance(string PointId)
        {
            double ret;
            listOfDistances.TryGetValue(PointId, out ret);
            return ret;
        }
    }


}
